package com.leo.imp;

import com.leo.abs.Digit;

public class BinarySystem extends Digit {

	@Override
	public double coverToNum(String number) {
		double value = 0;
		for(char ch : number.toCharArray()){
			value *= 2 ;
			if (ch == '1'){
				value ++;
			}
		}
		return value;
	}

	@Override
	public String coverToString(double number) {
		String value = "";
		int numberInt = (int) number;
		for (int mod = 0; numberInt > 0;numberInt /=2){
			mod = numberInt%2;
			value = mod + value;
		}
		return value;
	}

	@Override
	public boolean include(char ch) {
		if (ch == '1' || ch == '0')
			return true;
		return false;
	}

}
